//{=================================================================================
//! @file    Var1TaskA.c
//! @date    2013-29-09 19:18
//! @author  Andrianov Georgiy <egor.andrianov81@gmail.com>
//!
//! Finding prime numbers in a string of numbers.
//!
//}=================================================================================

#include <stdio.h>
#include <math.h>

int prost(int a);

int main()
{
    int i = 0, n = 0, k = 0;
    scanf("%i\n", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%i", &k);
        //printf("I has scanned %i. Process\n", k);
        if (prost(k) == 1)
        {
            //printf("%i is simple\n", k);
            printf("%i ", k);
        }
        else
        {
            //printf("%i isn't simple\n", k);
        }
    }
        //scanf("/n");
    return 0;
}

//! prost - determine is number prime or not prime
//!
//! @param      a   number
//!
//! @return         1 - if number is prime and 0 - if number oi not prime

int prost(int a)
{
    int i = 0;
    //printf("Process %i in prost()\n", a);
    for (i = 2; i <= sqrt(a); i++)
    {
        if (a % i == 0)
        {
            //printf("%i isn't simple\n", k);
            return 0;
        }
    }
    /*printf("\n");*/
    if (a == 1)
    {
        return 0;
    }
    return 1;
}
